home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 6.9 KB | 241 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: TblPart.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef TBLPART_H
- #define TBLPART_H
-
- // ----- TablePart Includes -----
-
- #ifndef TBLDEF_H
- #include "TblDef.h"
- #endif
-
- // ----- ODF Includes -----
-
- #ifndef FWPARTNG_H
- #include "FWPartng.h"
- #endif
-
- #ifndef FWMNUITM_H
- #include "FWMnuItm.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- const ODULong kMaxCols = 32;
- const ODULong kMaxRows = 32;
-
- // ----- Default size of cell -----
- const FW_CFixed kDefaultCellWidth = FW_IntToFixed(80);
- const FW_CFixed kDefaultCellHeight = FW_IntToFixed(80);
-
- // ----- Hit-test constants -----
- const FW_CFixed kPenWidth = FW_IntToFixed(1);
- const FW_CFixed kPenHeight = FW_IntToFixed(1);
-
- const FW_CFixed kVMargin = FW_IntToFixed(4); // width of vertical line margin
- const FW_CFixed kHMargin = FW_IntToFixed(4); // height of horz. line margin
-
- const FW_CFixed kBorderWidth = kPenWidth;
- const FW_CFixed kBorderHeight = kPenHeight;
-
- typedef short ETableLoc;
- const ETableLoc kTLNone = -1;
- const ETableLoc kTLCell = 0;
- const ETableLoc kTLLeftBorder = 1;
- const ETableLoc kTLRightBorder = 2;
- const ETableLoc kTLTopBorder = 4;
- const ETableLoc kTLBottomBorder = 8;
-
- // ----- Menus -----
-
- #ifdef FW_BUILD_WIN
- const short kEmbedMenu = 6;
- #endif
-
- // ----- Commands -----
- const ODCommandID cHideShowGrid = FW_kFirstUserCommandID;
-
- //==============================================================================
- // CCell Class
- //==============================================================================
-
- class CCell
- {
- public:
- CCell() {fX = 0; fY = 0;}
- CCell(short x, short y) {fX = x; fY = y;}
- CCell(const CCell& other) {fX = other.fX; fY = other.fY;}
- ~CCell() {}
-
- CCell& operator=(const CCell& other) {fX = other.fX; fY = other.fY; return *this;}
-
- FW_Boolean operator==(const CCell& other) const {return other.fX == fX && other.fY == fY;}
- FW_Boolean operator!=(const CCell& other) const {return other.fX != fX || other.fY != fY;}
-
- public:
- short fX;
- short fY;
- };
-
- //==============================================================================
- // Forward declarations
- //==============================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma import on
- #endif
- class FW_CLASS_ATTR FW_CDropCommand;
- class FW_CLASS_ATTR FW_CMenuBar;
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma import off
- #endif
-
- class FW_CLASS_ATTR CTableFrame;
- class FW_CLASS_ATTR CTableProxy;
- class FW_CLASS_ATTR CTableSelection;
- class FW_CLASS_ATTR CTableLinkManager;
-
- //==============================================================================
- // class CTablePart
- //==============================================================================
-
- class FW_CLASS_ATTR CTablePart : public FW_CEmbeddingPart
- {
- friend class CTableLinkManager;
-
- public:
- static const ODValueType kPartKind;
- static const ODValueType kPartUserName;
-
- //----------------------------------------------------------------------------------------
- // Initialization/Destruction
- //
- public:
- CTablePart(ODPart* odPart);
- virtual ~CTablePart();
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- virtual void Initialize(Environment* ev);
-
- // ----- Content I/O -----
- virtual void ExternalizeContent(Environment *ev, ODStorageUnit* storageUnit, FW_CCloneInfo* cloneInfo);
- virtual void InternalizeContent(Environment* ev, ODStorageUnit* storageUnit, FW_CCloneInfo* cloneInfo);
-
- // ----- Create Stuff -----
- virtual FW_CFrame* NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage);
-
- // ----- Linking Support -----
- virtual void ContentUpdated(Environment* ev,
- FW_CFrame* frame,
- ODUpdateID id); // Override
-
- virtual FW_Boolean DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot);
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- // ----- Menu Bar Initialization -----
- void InitializeMenuBar(Environment *ev, FW_CMenuBar *menuBar);
-
- // ----- Getters/setters -----
- const CCell& GetSize() const;
- FW_CFixed GetWidth (short c) const;
- FW_CFixed GetHeight(short r) const;
- void SetWidth (short c, FW_CFixed w);
- void SetHeight(short r, FW_CFixed h);
-
- // ----- For point on border, returned cell is above and to left -----
- ETableLoc HitTest(Environment* ev,
- const CTableFrame* frame,
- const FW_CPoint& where,
- CCell& cell) const;
-
- // ----- Coordinates from cell -----
- FW_CFixed FindLeft(short col) const;
- FW_CFixed FindTop (short row) const;
- void FindRect(const CCell& cell,
- FW_CRect& rect) const;
-
- CTableProxy* CellToProxy(Environment* ev, const CCell& cell) const;
-
- // ----- Resizing -----
- void Resize(Environment* ev,
- const CCell& cell,
- ETableLoc tl,
- const FW_CPoint& delta);
-
- // ----- Add/Remove proxys -----
- void AddProxy(CTableProxy* proxy);
- void RemoveProxy(CTableProxy* proxy);
-
- // ----- Linking Support -----
- FW_CLinkManager* NewLinkManager(Environment *ev); // Override
-
- FW_Boolean IsLinkSelected(Environment* ev);
-
- CTableSelection* GetTableSelection(Environment* ev);
-
- void RegisterSubscribers(Environment* ev);
- FW_Boolean ShowLinkInfo(Environment* ev, FW_CFrame* frame);
-
- void AboutToClearCell(Environment* ev, const CCell& cell);
- void ChangeFrameStatus(Environment* ev, const CCell& cell, ODLinkStatus newStatus);
- void ProxyMoved(Environment* ev, const CCell& fromCell, const CCell& toCell);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_CPrivOrderedCollection* fProxys;
-
- FW_CPresentation* fTablePresentation;
-
- // ----- Current size in memory -----
- CCell fCells;
-
- // ----- Width and height of cells -----
- FW_CFixed fWidth [kMaxCols];
- FW_CFixed fHeight[kMaxRows];
-
- CTableLinkManager* fTableLinkManager;
- FW_Boolean fSubscribersRegistered;
- };
-
- //========================================================================================
- // CTablePart Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CTablePart::GetSize
- //----------------------------------------------------------------------------------------
- inline const CCell& CTablePart::GetSize() const
- {
- return fCells;
- }
-
- #endif
-